﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.2.7    拆借借出信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_FIN_EXCLOANOUT: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_FIN_EXCLOANOUT()
		{}
		#region Model
		private long _id;
		private long _custid;
		private int _payment;
		private decimal _amt;
		private decimal _leftamt;
		private Nullable<DateTime> _startdate;
		private decimal _rate;
		private Nullable<DateTime> _enddate;
		private string _remark;
		private string _touser;
		private string _createby;
		private Nullable<DateTime> _createdate;
		private int _status;
		private int _clearstatus;
		private string _clearby;
		private Nullable<DateTime> _cleardate;
		private int _sparefield1;
		private string _sparefield2;
		private string _sparefield3;
		/// <summary>
		/// 记录ID
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 客户记录ID
		/// </summary>
		[DataMember]
		public long CUSTID
		{
			get{return _custid;}
			set{
				if ( _custid!= value)
				{
					 _custid = value;
					OnPropertyChanged("CUSTID");
				}
			}
		}
		/// <summary>
		/// 利息计算参数1算头不算尾，2算头算尾,默认为1
		/// </summary>
		[DataMember]
		public int PAYMENT
		{
			get{return _payment;}
			set{
				if ( _payment!= value)
				{
					 _payment = value;
					OnPropertyChanged("PAYMENT");
				}
			}
		}
		/// <summary>
		/// 借款金额
		/// </summary>
		[DataMember]
		public decimal AMT
		{
			get{return _amt;}
			set{
				if ( _amt!= value)
				{
					 _amt = value;
					OnPropertyChanged("AMT");
				}
			}
		}
		/// <summary>
		/// 结欠金额
		/// </summary>
		[DataMember]
		public decimal LEFTAMT
		{
			get{return _leftamt;}
			set{
				if ( _leftamt!= value)
				{
					 _leftamt = value;
					OnPropertyChanged("LEFTAMT");
				}
			}
		}
		/// <summary>
		/// 计息日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> STARTDATE
		{
			get{return _startdate;}
			set{
				if ( _startdate!= value)
				{
					 _startdate = value;
					OnPropertyChanged("STARTDATE");
				}
			}
		}
		/// <summary>
		/// 借款利率
		/// </summary>
		[DataMember]
		public decimal RATE
		{
			get{return _rate;}
			set{
				if ( _rate!= value)
				{
					 _rate = value;
					OnPropertyChanged("RATE");
				}
			}
		}
		/// <summary>
		/// 到期日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> ENDDATE
		{
			get{return _enddate;}
			set{
				if ( _enddate!= value)
				{
					 _enddate = value;
					OnPropertyChanged("ENDDATE");
				}
			}
		}
		/// <summary>
		/// 备注
		/// </summary>
		[DataMember]
		public string REMARK
		{
			get{return _remark;}
			set{
				if ( _remark!= value)
				{
					 _remark = value;
					OnPropertyChanged("REMARK");
				}
			}
		}
		/// <summary>
		/// 提交到
		/// </summary>
		[DataMember]
		public string TOUSER
		{
			get{return _touser;}
			set{
				if ( _touser!= value)
				{
					 _touser = value;
					OnPropertyChanged("TOUSER");
				}
			}
		}
		/// <summary>
		/// 录入人
		/// </summary>
		[DataMember]
		public string CREATEBY
		{
			get{return _createby;}
			set{
				if ( _createby!= value)
				{
					 _createby = value;
					OnPropertyChanged("CREATEBY");
				}
			}
		}
		/// <summary>
		/// 录入时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CREATEDATE
		{
			get{return _createdate;}
			set{
				if ( _createdate!= value)
				{
					 _createdate = value;
					OnPropertyChanged("CREATEDATE");
				}
			}
		}
		/// <summary>
		/// 状态0保存，1提交,2已审批通过，3拒绝
		/// </summary>
		[DataMember]
		public int STATUS
		{
			get{return _status;}
			set{
				if ( _status!= value)
				{
					 _status = value;
					OnPropertyChanged("STATUS");
				}
			}
		}
		/// <summary>
		/// 结清状态0否，1是
		/// </summary>
		[DataMember]
		public int CLEARSTATUS
		{
			get{return _clearstatus;}
			set{
				if ( _clearstatus!= value)
				{
					 _clearstatus = value;
					OnPropertyChanged("CLEARSTATUS");
				}
			}
		}
		/// <summary>
		/// 结清人
		/// </summary>
		[DataMember]
		public string CLEARBY
		{
			get{return _clearby;}
			set{
				if ( _clearby!= value)
				{
					 _clearby = value;
					OnPropertyChanged("CLEARBY");
				}
			}
		}
		/// <summary>
		/// 结清时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CLEARDATE
		{
			get{return _cleardate;}
			set{
				if ( _cleardate!= value)
				{
					 _cleardate = value;
					OnPropertyChanged("CLEARDATE");
				}
			}
		}
		/// <summary>
		/// 预留字段1
		/// </summary>
		[DataMember]
		public int SPAREFIELD1
		{
			get{return _sparefield1;}
			set{
				if ( _sparefield1!= value)
				{
					 _sparefield1 = value;
					OnPropertyChanged("SPAREFIELD1");
				}
			}
		}
		/// <summary>
		/// 预留字段2
		/// </summary>
		[DataMember]
		public string SPAREFIELD2
		{
			get{return _sparefield2;}
			set{
				if ( _sparefield2!= value)
				{
					 _sparefield2 = value;
					OnPropertyChanged("SPAREFIELD2");
				}
			}
		}
		/// <summary>
		/// 预留字段3
		/// </summary>
		[DataMember]
		public string SPAREFIELD3
		{
			get{return _sparefield3;}
			set{
				if ( _sparefield3!= value)
				{
					 _sparefield3 = value;
					OnPropertyChanged("SPAREFIELD3");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

